package com.wu.flandre.component;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


/**
 * 多次获取request的包装类
 *
 * @author 50816
 * @date 2019年12月1日 18:42:04
 */
@Slf4j
public class RequestWrapperFilter implements Filter {


    @Override
    public void init(FilterConfig filterConfig) {
        log.info("requestWrapperFilter init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        ServletRequest requestWrapper = new UserRequestWrapper((HttpServletRequest) servletRequest);
        filterChain.doFilter(requestWrapper, servletResponse);
    }

    @Override
    public void destroy() {
        log.info("requestWrapperFilter destroy");
    }
}
